No. You need 4 cups of flour and 2 cups of sugar. Now you have more than enough flour, but not enough sugar, so you can't follow the recipe.
In order to bake cookies two things must be true:
If one of these requirements is false, then you do not have enough ingredients. A QBasic program that follows this logic is:
' Cookie Ingredients Checker ' PRINT "How much flour do you have" INPUT FLOUR PRINT "How much sugar do you have" INPUT SUGAR ' IF FLOUR >= 4 AND SUGAR >= 2 THEN PRINT "You have enough ingredients" ELSE PRINT "You do not have enough" END IF ' END
The IF
statement
is asking a question with two parts:
IF FLOUR >= 4 AND SUGAR >= 2 THEN ---------- ---------- flour part sugar part
Each one of these parts is a relational expression (as in the previous chapters.) A relational expression looks at two numbers and gives you TRUE or FALSE.
Say that you enter 9 for FLOUR and 1 for SUGAR. What answer (TRUE or FALSE) does each of the parts give you?
FLOUR >= 4 ________________ SUGAR >= 2 ________________